<template>
<div>
  <span>
      人员信息
  </span>
  <el-divider />
  <el-form :model="userInfoFormValue" v-loading="userLoading" label-width="100">
    <div style="display: flex;">
      <el-form-item label="部门" style="flex: 1; margin-right: 20px;">
        <el-input :disabled = "true" v-model="userInfoFormValue.deptName" />
      </el-form-item>
      <el-form-item label="姓名" style="flex: 1; margin-right: 20px;">
        <el-input :disabled = "true" v-model="userInfoFormValue.userName" />
      </el-form-item>
      <el-form-item label="身份证号" style="flex: 1; margin-right: 20px;">
        <el-input :disabled = "true" v-model="userInfoFormValue.userIdNumber" />
      </el-form-item>
      <el-form-item label="工号" style="flex: 1; margin-right: 20px;">
        <el-input :disabled = "true" v-model="userInfoFormValue.jobNumber" />
      </el-form-item>
    </div>
    <div style="display: flex;">
      <el-form-item label="性别" style="flex: 1; margin-right: 20px;">
        <el-input :disabled = "true" v-model="userInfoFormValue.userSex" />
      </el-form-item>
      <el-form-item label="身份类别" style="flex: 1; margin-right: 20px;">
        <el-input :disabled = "true" v-model="userInfoFormValue.userCategory" />
      </el-form-item>
      <el-form-item label="最高学历" style="flex: 1; margin-right: 20px;">
        <el-input :disabled = "true" v-model="userInfoFormValue.highestEducation" />
      </el-form-item>
      <el-form-item label="毕业时间" style="flex: 1; margin-right: 20px;">
        <el-input :disabled = "true" v-model="userInfoFormValue.graduationTime" />
      </el-form-item>
    </div>
  </el-form>
  <span>
      基本信息
  </span>
  <el-divider />
  <el-form :model="salaryFormValue" v-loading="loading" label-width="100">
    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="状态" style="flex: 1; margin-right: 20px;">
          <el-select :disabled = "isDisabled" placeholder="未知" v-model="salaryFormValue.salaryStatus">
            <el-option label="正常" :value="200" />
            <el-option label="退休" :value="400" />
            <el-option label="离休" :value="500" />
            <el-option label="停薪" :value="600" />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="归属部门" style="flex: 1; margin-right: 20px;">
          <el-select :disabled = "isDisabled" filterable
                     v-model="salaryFormValue.salaryDeptId"
          >
            <el-option
                v-for="item in deptData"
                :key="item.id"
                :label="item.deptName"
                :value="item.id"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="起薪时间" style="flex: 1; margin-right: 20px;">
          <el-date-picker :disabled = "isDisabled" v-model="salaryFormValue.startSalaryData" type="date" value-format="YYYY-MM-DD" placeholder="选择起薪时间" style="width: 100%";/>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="是否教学系列" style="flex: 1; margin-right: 20px;">
          <el-select :disabled = "isDisabled" placeholder="未知" v-model="salaryFormValue.isTeachSeries">
            <el-option label="是" :value="1" />
            <el-option label="否" :value="0" />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="事业编制内" style="flex: 1; margin-right: 20px;">
          <el-select :disabled = "isDisabled" placeholder="未知" v-model="salaryFormValue.governmentStaff">
            <el-option label="是" :value="1" />
            <el-option label="否" :value="0" />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="是否协议工资" style="flex: 1; margin-right: 20px;">
          <el-select :disabled = "isDisabled" placeholder="未知" v-model="salaryFormValue.isAgreeSalary">
            <el-option label="是" :value="1" />
            <el-option label="否" :value="0" />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="协议工资" style="flex: 1; margin-right: 20px;">
          <el-input :disabled = "isDisabled || salaryFormValue.isAgreeSalary !== 1" v-model="salaryFormValue.agreeSalary" />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="停薪时间" style="flex: 1; margin-right: 20px;">
          <el-date-picker :disabled = "isDisabled || salaryFormValue.salaryStatus !== 600" v-model="salaryFormValue.stopData" type="date" value-format="YYYY-MM-DD" placeholder="停止发薪月" style="width: 100%" ;/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="停薪类型" style="flex: 1; margin-right: 20px;">
          <el-select :disabled = "isDisabled || salaryFormValue.salaryStatus !== 600" placeholder="未知" v-model="salaryFormValue.stopType">
            <el-option label="离职" :value="1" />
            <el-option label="退休去世" :value="2" />
            <el-option label="在职去世" :value="3" />
            <el-option label="其他" :value="4" />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="停薪原因" style="flex: 1; margin-right: 20px;">
          <el-input :disabled = "isDisabled || salaryFormValue.salaryStatus !== 600" v-model="salaryFormValue.stopReason" />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="备注" style="flex: 1; margin-right: 20px;">
          <el-input :disabled = "isDisabled" v-model="salaryFormValue.remark" />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>

  <el-tabs v-model="activeName" class="tabs">
    <el-tab-pane label="档案薪资" name="salaryFile">
      <el-form :model="salaryFileFormValue" v-loading="loading" label-width="100">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="岗位类别" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryFileFormValue.filePostTypeId"
                  placeholder="选择岗位类别"
                  :disabled = "isDisabled"
                  @change="salaryFile_PostTypeChange()"
              >
                <el-option
                    v-for="item in systemPostTypeList"
                    :key="item.id"
                    :label="item.postTypeName"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="岗位" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryFileFormValue.filePostId"
                  placeholder="选择岗位"
                  :disabled = "isDisabled"
              >
                <el-option
                    v-for="item in salaryFile_PostList"
                    :key="item.id"
                    :label="item.postRankName"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="薪级" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryFileFormValue.fileLevelId"
                  placeholder="选择薪级"
                  :disabled = "isDisabled"
              >
                <el-option
                    v-for="item in salaryFile_LevelList"
                    :key="item.id"
                    :label="item.levelRank"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-button type="warning" :disabled = "isDisabled" @click="calculateFileSalary">自动计算</el-button>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="岗位说明" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryFileFormValue.postDescribe" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="岗位工资" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryFileFormValue.filePostSalary" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="薪级说明" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryFileFormValue.levelDescribe" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="薪级工资" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryFileFormValue.fileLevelSalary" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="备注" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryFileFormValue.remark" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-tab-pane>
    <el-tab-pane label="薪级薪资" name="salaryLevel">
      <el-form :model="salaryLevelFormValue" v-loading="loading" label-width="100">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="岗位类别" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryLevelFormValue.postTypeId"
                  placeholder="选择岗位类别"
                  :disabled = "isDisabled"
                  @change="salaryLevel_PostTypeChange()"
              >
                <el-option
                    v-for="item in systemPostTypeList"
                    :key="item.id"
                    :label="item.postTypeName"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="薪级" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryLevelFormValue.levelId"
                  placeholder="选择薪级"
                  :disabled = "isDisabled"
              >
                <el-option
                    v-for="item in salaryLevel_LevelList"
                    :key="item.id"
                    :label="item.levelRank"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-button type="primary" :disabled = "isDisabled" @click="levelQuoteFile">引用档案</el-button>
            <el-button type="warning" :disabled = "isDisabled" @click="calculateLevelSalary">自动计算</el-button>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="岗位说明" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryLevelFormValue.postDescribe" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="薪级说明" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryLevelFormValue.levelDescribe" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="薪级工资" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryLevelFormValue.levelSalary" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="备注" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryLevelFormValue.remark" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-tab-pane>
    <el-tab-pane label="管理责任" name="salaryManage">
      <el-form :model="salaryManageFormValue" v-loading="loading" label-width="100">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="岗位类别" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryManageFormValue.postTypeId"
                  placeholder="选择岗位类别"
                  :disabled = "isDisabled"
                  @change="salaryManager_PostTypeChange()"
              >
                <el-option
                    v-for="item in systemPostTypeList"
                    :key="item.id"
                    :label="item.postTypeName"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="岗位" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryManageFormValue.postId"
                  placeholder="选择岗位"
                  :disabled = "isDisabled"
              >
                <el-option
                    v-for="item in salaryManage_postList"
                    :key="item.id"
                    :label="item.postRankName"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-button type="primary" :disabled = "isDisabled" @click="managerQuoteFile">引用档案</el-button>
            <el-button type="warning" :disabled = "isDisabled" @click="calculateManagerSalary">自动计算</el-button>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="岗位说明" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryManageFormValue.postDescribe" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="管理责任" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryManageFormValue.manager" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="管理责任津贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryManageFormValue.manageAllowance" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-tab-pane>
    <el-tab-pane label="基本工资" name="salaryOne">
      <el-form :model="salaryOneFormValue" v-loading="loading" label-width="100">

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="岗位类别" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryOneFormValue.postTypeId"
                  placeholder="选择岗位类别"
                  :disabled = "isDisabled"
                  @change="salaryOne_PostTypeChange()"
              >
                <el-option
                    v-for="item in systemPostTypeList"
                    :key="item.id"
                    :label="item.postTypeName"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="岗位" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryOneFormValue.postId"
                  placeholder="选择岗位"
                  :disabled = "isDisabled"
              >
                <el-option
                    v-for="item in salaryOne_postList"
                    :key="item.id"
                    :label="item.postRankName"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-button type="primary" :disabled = "isDisabled" @click="oneQuoteFile">引用档案</el-button>
            <el-button type="warning" :disabled = "isDisabled" @click="calculateOneSalary">自动计算</el-button>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="岗位说明" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryOneFormValue.postDescribe" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="岗位工资" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryOneFormValue.postSalary" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="基础绩效奖" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryOneFormValue.performanceAward" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-tab-pane>
    <el-tab-pane label="绩效工资" name="salaryTwo">
      <el-form :model="salaryTwoFormValue" v-loading="loading" label-width="100">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="岗位类别" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryTwoFormValue.postTypeId"
                  placeholder="选择岗位类别"
                  :disabled = "isDisabled"
                  @change="salaryTwo_PostTypeChange()"
              >
                <el-option
                    v-for="item in systemPostTypeList"
                    :key="item.id"
                    :label="item.postTypeName"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="岗位" style="flex: 1; margin-right: 20px;">
              <el-select
                  v-model="salaryTwoFormValue.postId"
                  placeholder="选择岗位"
                  :disabled = "isDisabled"
              >
                <el-option
                    v-for="item in salaryTwo_postList"
                    :key="item.id"
                    :label="item.postRankName"
                    :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-button type="primary" :disabled = "isDisabled" @click="twoQuoteFile">引用档案</el-button>
            <el-button type="warning" :disabled = "isDisabled" @click="calculateTwoSalary">自动计算</el-button>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="岗位说明" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryTwoFormValue.postDescribe" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="基础津贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryTwoFormValue.basicAllowance" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="岗位津贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryTwoFormValue.postAllowance" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="基本业绩奖励" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryTwoFormValue.achievementAward" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="备注" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryTwoFormValue.remark" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-tab-pane>
    <el-tab-pane>
      <template #label>
        <span>补贴津贴</span>
        <el-switch
            v-model="salarySubsidyNewOldSwitch"
            inline-prompt
            active-text="新"
            inactive-text="旧"
            size="small"
            style="margin: 0px 0px 0px 5px;"
        ></el-switch>
      </template>
      <el-form :model="salarySubsidyFormValue" v-loading="loading" label-width="100">

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="物业补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.propertySubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="保密补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.secrecySubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="思政津贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.politicalAllowance" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="辅导员津贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.instructorAllowance" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="博士津贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.doctorAllowance" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="博士津贴开始" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.doctorAllowanceStart" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="交通补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.trafficSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="独生子补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.onlyChildSubsidy" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="租房补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.rentalSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="教护龄" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.nursingAge" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="办案补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.handleSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="工资百分之10" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.salary10" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20" v-if="!salarySubsidyNewOldSwitch">
          <el-col :span="6">
            <el-form-item label="岗位补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.postSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="通勤补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.commutingSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="误餐补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.missMealsSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="驾驶员补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.driverAllowance" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="20" v-if="!salarySubsidyNewOldSwitch">
          <el-col :span="6" >
            <el-form-item label="老干部补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.veteranCadreSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="计生补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.familyPlanningSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="国贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.countrySubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="省定职补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.provinceJobSubsidy" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20" v-if="!salarySubsidyNewOldSwitch">
          <el-col :span="6" >
            <el-form-item label="市定职补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.cityJobSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6" >
            <el-form-item label="租房补贴时间" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salarySubsidyFormValue.rentalSubsidyDate" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-tab-pane>
    <el-tab-pane label="公积金" name="salaryHouseFunds">
      <el-button type="warning" :disabled = "isDisabled" @click="addHouseFunds">新增</el-button>
      <el-table :data="salaryHouseFundsFormValue">
        <el-table-column property="fundCardinal" label="公积金基数" />
        <el-table-column property="fundStandard" label="公积金标准"/>
        <el-table-column property="belongYear" label="执行年" />
        <el-table-column property="currentYear" label="当前年">
          <template #default="scope">
            {{ formatHouseFundsCurrentYear(scope.row.currentYear) }}
          </template>
        </el-table-column>
        <el-table-column property="remark" label="备注" />
        <el-table-column label="操作">
          <template #default="scope">
            <el-button size="small" type="danger" :disabled = "isDisabled" @click="handleHouseFundsDelete(scope.$index)">
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-tab-pane>
    <el-tab-pane label="社保" name="salaryInsurance">
      <el-button type="warning" :disabled = "isDisabled" @click="insuranceCalculateTools" style="margin-bottom: 20px;">计算工具</el-button>
      <el-form :model="salaryInsuranceFormValue" v-loading="loading" label-width="100">
        <div style="display: flex;">
          <el-form-item label="社保基数" style="flex: 1; margin-right: 20px;">
            <el-input :disabled = "isDisabled" v-model="salaryInsuranceFormValue.socialCardinal" />
          </el-form-item>
          <el-form-item label="医保基数" style="flex: 1; margin-right: 20px;">
            <el-input :disabled = "isDisabled" v-model="salaryInsuranceFormValue.medicalCardinal" />
          </el-form-item>
          <el-form-item label="养老基数" style="flex: 1; margin-right: 20px;">
            <el-input :disabled = "isDisabled" v-model="salaryInsuranceFormValue.endowmentCardinal" />
          </el-form-item>
          <el-form-item label="医疗保险" style="flex: 1; margin-right: 20px;">
            <el-input :disabled = "isDisabled" v-model="salaryInsuranceFormValue.medicalInsurance" />
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item label="失业保险" style="flex: 1; margin-right: 20px;">
            <el-input :disabled = "isDisabled" v-model="salaryInsuranceFormValue.careerInsurance" />
          </el-form-item>
          <el-form-item label="养老保险" style="flex: 1; margin-right: 20px;">
            <el-input :disabled = "isDisabled" v-model="salaryInsuranceFormValue.endowmentInsurance" />
          </el-form-item>
          <el-form-item label="职业年金" style="flex: 1; margin-right: 20px;">
            <el-input :disabled = "isDisabled" v-model="salaryInsuranceFormValue.occupationAnnuity" />
          </el-form-item>
          <el-form-item label="工会会费" style="flex: 1; margin-right: 20px;">
            <el-input :disabled = "isDisabled" v-model="salaryInsuranceFormValue.unionDues" />
          </el-form-item>
        </div>
      </el-form>
    </el-tab-pane>
    <el-tab-pane>
      <template #label>
        <span>退休待遇</span>
        <el-switch
            v-model="salaryRetireNewOldSwitch"
            inline-prompt
            active-text="新"
            inactive-text="旧"
            size="small"
            style="margin: 0px 0px 0px 5px;"
        ></el-switch>
      </template>
      <el-form :model="salaryRetireFormValue" v-loading="loading" label-width="100">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="退休类型" style="flex: 1; margin-right: 20px;">
              <el-select :disabled = "isDisabled" placeholder="退休类型" v-model="salaryRetireFormValue.retireType">
                <el-option label="到年龄退休" :value="1" />
                <el-option label="提前退休" :value="2" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="转入部门" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.retireTo" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="退休时间" style="flex: 1; margin-right: 20px;">
              <el-date-picker :disabled = "isDisabled" v-model="salaryRetireFormValue.retireTime" type="date" value-format="YYYY-MM-DD" placeholder="选择退休时间" style="width: 100%"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="办理时间" style="flex: 1; margin-right: 20px;">
              <el-date-picker :disabled = "isDisabled" v-model="salaryRetireFormValue.retireDealTime" type="date" value-format="YYYY-MM-DD" placeholder="选择退休办理时间" style="width: 100%"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="基本退休费" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.basicRetirePay" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="提高比例%" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.increaseScale" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="合计比例%" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.totalScale" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="校内补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.schoolSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.otherSubsidy" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="物业补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.propertySubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="交通补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.trafficSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="通讯补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.phoneSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="独生子补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.onlyChildSubsidy" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20" v-if="!salaryRetireNewOldSwitch">
          <el-col :span="6">
            <el-form-item label="岗位补贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.postSubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="市补贴标准" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.citySubsidyStandard" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="市定职补" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.citySubsidy" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="校补贴标准" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.schoolSubsidyStandard" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20" v-if="!salaryRetireNewOldSwitch">
          <el-col :span="6">
            <el-form-item label="工资_10" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.salary10" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="教护龄" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.nursingAge" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="创卫浮动" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.cwfd" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="未冲津贴" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.wcjt" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" v-if="!salaryRetireNewOldSwitch">
          <el-col :span="6">
            <el-form-item label="预发工资" style="flex: 1; margin-right: 20px;">
              <el-input :disabled = "isDisabled" v-model="salaryRetireFormValue.yfgz" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-tab-pane>
  </el-tabs>

  <el-dialog v-model="houseFundsDialogVisible" title="公积金计算" width="1000">
    <el-form :model="houseFundsCalculateForm" label-width="100">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="岗位类别" style="flex: 1; margin-right: 10px;">
            <el-select
                v-model="houseFundsCalculateForm.postTypeId"
                placeholder="选择岗位类别"
                :disabled = "isDisabled"
                @change="houseFundsCalculateForm_PostTypeChange()"
            >
              <el-option
                  v-for="item in systemPostTypeList"
                  :key="item.id"
                  :label="item.postTypeName"
                  :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="岗位" style="flex: 1; margin-right: 10px;">
            <el-select
                v-model="houseFundsCalculateForm.postId"
                placeholder="选择岗位"
                :disabled = "isDisabled"
            >
              <el-option
                  v-for="item in houseFundsCalculateForm_postList"
                  :key="item.id"
                  :label="item.postRankName"
                  :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="薪级" style="flex: 1; margin-right: 10px;">
            <el-select
                v-model="houseFundsCalculateForm.levelId"
                placeholder="选择薪级"
                :disabled = "isDisabled"
            >
              <el-option
                  v-for="item in houseFundsCalculateForm_LevelList"
                  :key="item.id"
                  :label="item.levelRank"
                  :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-button type="primary" :disabled = "isDisabled" @click="houseFundsCalculateFormQuoteFile">引用档案</el-button>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="执行年" style="flex: 1; margin-right: 10px;">
            <el-date-picker :disabled = "isDisabled" v-model="houseFundsCalculateForm.belongYear" format="YYYY" value-format="YYYY" type="year" placeholder="执行年" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="当前年" style="flex: 1; margin-right: 10px;">
            <el-switch v-model="houseFundsCalculateForm.currentYear"  :active-value="1" :inactive-value="0"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="备注" style="flex: 1; margin-right: 10px;">
            <el-input :disabled = "isDisabled" v-model="houseFundsCalculateForm.remark" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-button type="warning" :disabled = "isDisabled" @click="calculateHouseFunds" style="margin-bottom: 20px;">自动计算</el-button>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="公积金基数：" style="flex: 1; margin-right: 10px;">
            <span>{{houseFundsCalculateResult.fundCardinalFormula}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="公积金标准：" style="flex: 1; margin-right: 10px;">
            <span>{{houseFundsCalculateResult.fundStandardFormula}}</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="houseFundsDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="houseFundsDialogConfirm">确认</el-button>
      </div>
    </template>
  </el-dialog>
  <el-dialog v-model="insuranceDialogVisible" title="社保计算" width="1000">
    <el-form :model="insuranceCalculateForm" label-width="100">
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="岗位类别" style="flex: 1; margin-right: 10px;">
            <el-select
                v-model="insuranceCalculateForm.postTypeId"
                placeholder="选择岗位类别"
                :disabled = "isDisabled"
                @change="insuranceCalculateForm_PostTypeChange()"
            >
              <el-option
                  v-for="item in systemPostTypeList"
                  :key="item.id"
                  :label="item.postTypeName"
                  :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="岗位" style="flex: 1; margin-right: 10px;">
            <el-select
                v-model="insuranceCalculateForm.postId"
                placeholder="选择岗位"
                :disabled = "isDisabled"
            >
              <el-option
                  v-for="item in insuranceCalculateForm_postList"
                  :key="item.id"
                  :label="item.postRankName"
                  :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="薪级" style="flex: 1; margin-right: 10px;">
            <el-select
                v-model="insuranceCalculateForm.levelId"
                placeholder="选择薪级"
                :disabled = "isDisabled"
            >
              <el-option
                  v-for="item in insuranceCalculateForm_LevelList"
                  :key="item.id"
                  :label="item.levelRank"
                  :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="事业编制内" style="flex: 1; margin-right: 10px;">
            <el-select :disabled = "isDisabled" placeholder="未知" v-model="insuranceCalculateForm.governmentStaff">
              <el-option label="是" :value="1" />
              <el-option label="否" :value="0" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-button type="primary" :disabled = "isDisabled" @click="insuranceCalculateFormQuoteFile" style="margin-bottom: 20px;">引用档案</el-button>
          <el-button type="warning" :disabled = "isDisabled" @click="calculateInsurance" style="margin-bottom: 20px;">自动计算</el-button>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="社保基数：" style="flex: 1; margin-right: 10px;">
            <span>{{insuranceCalculateResult.socialCardinalFormula}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="养老基数：" style="flex: 1; margin-right: 10px;">
            <span>{{insuranceCalculateResult.endowmentCardinalFormula}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="医保基数：" style="flex: 1; margin-right: 10px;">
            <span>{{insuranceCalculateResult.medicalCardinalFormula}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="医疗保险：" style="flex: 1; margin-right: 10px;">
            <span>{{insuranceCalculateResult.medicalInsuranceFormula}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="失业保险：" style="flex: 1; margin-right: 10px;">
            <span>{{insuranceCalculateResult.careerInsuranceFormula}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="养老保险：" style="flex: 1; margin-right: 10px;">
            <span>{{insuranceCalculateResult.endowmentInsuranceFormula}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="职业年金：" style="flex: 1; margin-right: 10px;">
            <span>{{insuranceCalculateResult.occupationAnnuityFormula}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="工会会费：" style="flex: 1; margin-right: 10px;">
            <span>{{insuranceCalculateResult.unionDuesFormula}}</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="insuranceDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="insuranceDialogConfirm">确认</el-button>
      </div>
    </template>
  </el-dialog>
</div>
</template>

<script setup>
import {onMounted, reactive, ref} from "vue";
import {useRoute, useRouter} from 'vue-router'
import Salary from '@/api/Salary.js';
import UserBasic from '@/api/UserBasic.js';
import SystemPostType from '@/api/SystemPostType.js';
import SystemPost from '@/api/SystemPost.js';
import SalaryLevel from '@/api/SalaryLevel.js';
import {ElMessage} from "element-plus";
import Dept from "@/api/Dept.js";

const route = useRoute()

const userId = ref('')


const activeName = ref('salaryFile')
const salarySubsidyNewOldSwitch = ref(true)
const salaryRetireNewOldSwitch = ref(true)
const loading = ref(false)
const userLoading = ref(false)
const houseFundsDialogVisible = ref(false)
const insuranceDialogVisible = ref(false)
const map = {
  1: '是',
  0: '否',
}

const formatHouseFundsCurrentYear = (currentYear) => {
  return map[currentYear]
}
const deptData = ref([]);
const userInfoFormValue = ref({
  id:'',
  deptName:'',
  userName:'',
  userIdNumber:'',
  jobNumber:'',
  userSex:'',
  userCategory:'',
  highestEducation:'',
  graduationTime:''
})
const salaryFormValue = ref({
  salaryStatus:200,
  salaryDeptId:'',
  startSalaryData:'',
  isTeachSeries:'',
  governmentStaff:'',
  stopData:'',
  stopType:'',
  stopReason:'',
  isAgreeSalary:'',
  agreeSalary:'',
  remark:''
})
const salaryFileFormValue = ref({
  filePostTypeId:'',
  filePostId:'',
  postDescribe:'',
  filePostSalary:'',
  fileLevelId:'',
  levelDescribe:'',
  fileLevelSalary:'',
  remark:''
})
const salaryLevelFormValue = ref({
  postTypeId:'',
  postDescribe:'',
  levelId:'',
  levelDescribe:'',
  levelSalary:'',
  remark:''
})
const salaryManageFormValue = ref({
  postTypeId:'',
  postId:'',
  postDescribe:'',
  manager:'',
  manageAllowance:'',
})
const salaryOneFormValue = ref({
  postTypeId:'',
  postId:'',
  postDescribe:'',
  postSalary:'',
  performanceAward:''
})
const salaryTwoFormValue = ref({
  postTypeId:'',
  postId:'',
  postDescribe:'',
  basicAllowance:'',
  postAllowance:'',
  achievementAward:'',
  remark:''
})
const salarySubsidyFormValue = ref({
  postSubsidy:'',
  propertySubsidy:'',
  trafficSubsidy:'',
  phoneSubsidy:'',
  secrecySubsidy:'',
  handleSubsidy:'',
  doctorAllowance:'',
  doctorAllowanceStart:'',
  instructorAllowance:'',
  politicalAllowance:'',
  commutingSubsidy:'',
  onlyChildSubsidy:'',
  rentalSubsidy:'',
  rentalSubsidyDate:'',
  salary10:'',
  nursingAge:'',
  missMealsSubsidy:'',
  driverAllowance:'',
  veteranCadreSubsidy:'',
  familyPlanningSubsidy:'',
  countrySubsidy:'',
  provinceJobSubsidy:'',
  cityJobSubsidy:''
})
const salaryHouseFundsFormValue = ref([])
const salaryInsuranceFormValue = ref({
  socialCardinal:'',
  medicalCardinal:'',
  endowmentCardinal:'',
  medicalInsurance:'',
  careerInsurance:'',
  endowmentInsurance:'',
  occupationAnnuity:'',
  unionDues:'',
  remark:''
})
const houseFundsCalculateForm = ref({
  postTypeId:'',
  postId:'',
  levelId:'',
  belongYear:'',
  currentYear: 1,
  remark: '',
})
const insuranceCalculateForm = ref({
  governmentStaff:'',
  postTypeId:'',
  postId:'',
  levelId:'',
})
const houseFundsCalculateResult = ref({
  fundCardinalFormula:'',
  fundCardinal:'',
  fundStandardFormula:'',
  fundStandard:'',
})
const insuranceCalculateResult = ref({
  socialCardinal:'',
  socialCardinalFormula:'',
  medicalCardinal:'',
  medicalCardinalFormula:'',
  endowmentCardinal:'',
  endowmentCardinalFormula:'',
  medicalInsurance:'',
  medicalInsuranceFormula:'',
  careerInsurance:'',
  careerInsuranceFormula:'',
  endowmentInsurance:'',
  endowmentInsuranceFormula:'',
  occupationAnnuity:'',
  occupationAnnuityFormula:'',
  unionDues:'',
  unionDuesFormula:'',
})
const salaryRetireFormValue = ref({
  retireType:1,
  retireTo:'离退休工作处',
  retireTime:'',
  retireDealTime:'',


  basicRetirePay:'',
  increaseScale:'',
  totalScale:'',
  postSubsidy:'',
  citySubsidyStandard:'',
  citySubsidy:'',
  schoolSubsidyStandard:'',
  schoolSubsidy:'',




  propertySubsidy:'',
  trafficSubsidy:'',
  phoneSubsidy:'',
  otherSubsidy:'',


  onlyChildSubsidy:'',
  salary10:'',
  nursingAge:'',
  cwfd:'',
  wcjt:'',
  yfgz:'',
})


const systemPostTypeList= ref([])
const salaryFile_PostList= ref([])
const salaryManage_postList= ref([])
const salaryOne_postList= ref([])
const salaryTwo_postList= ref([])
const houseFundsCalculateForm_postList= ref([])
const insuranceCalculateForm_postList= ref([])

const salaryFile_LevelList= ref([])
const salaryLevel_LevelList= ref([])
const houseFundsCalculateForm_LevelList= ref([])
const insuranceCalculateForm_LevelList= ref([])

const props = defineProps({
  isDisabled: {
    type: Boolean,
    default: true
  },
  type: {
    type: String,
    default: 'detail',
    validator: (val) => ['detail', 'update', 'save'].includes(val)
  },
});

const salaryFile_PostTypeChange = async () => {
  if (salaryFileFormValue.value.filePostTypeId) {
    const body = ref({
      postTypeId: salaryFileFormValue.value.filePostTypeId
    })
    // salaryFileFormValue.value.filePostId = undefined
    // salaryFileFormValue.value.fileLevelId = undefined
    SystemPost.querySystemPostByType(body.value)
        .then(res => {
          salaryFile_PostList.value = res.data
        })
    SalaryLevel.querySystemLevelByType(body.value)
        .then(res => {
          salaryFile_LevelList.value = res.data
        })
  }
}

const salaryManager_PostTypeChange = () => {
  if (salaryManageFormValue.value.postTypeId) {
    const body = ref({
      postTypeId: salaryManageFormValue.value.postTypeId
    })
    // salaryManageFormValue.value.postId = undefined
    SystemPost.querySystemPostByType(body.value)
        .then(res => {
          salaryManage_postList.value = res.data
        })
  }
}

const salaryOne_PostTypeChange = () => {
  if (salaryOneFormValue.value.postTypeId) {
    const body = ref({
      postTypeId: salaryOneFormValue.value.postTypeId
    })
    // salaryOneFormValue.value.postId = undefined
    SystemPost.querySystemPostByType(body.value)
        .then(res => {
          salaryOne_postList.value = res.data
        })
  }
}

const salaryTwo_PostTypeChange = () => {
  if (salaryTwoFormValue.value.postTypeId) {
    const body = ref({
      postTypeId: salaryTwoFormValue.value.postTypeId
    })
    // salaryTwoFormValue.value.postId = undefined
    SystemPost.querySystemPostByType(body.value)
        .then(res => {
          salaryTwo_postList.value = res.data
        })
  }
}

const salaryLevel_PostTypeChange = () => {
  if (salaryLevelFormValue.value.postTypeId) {
    const body = ref({
      postTypeId: salaryLevelFormValue.value.postTypeId
    })
    // salaryLevelFormValue.value.levelId = undefined
    SalaryLevel.querySystemLevelByType(body.value)
        .then(res => {
          salaryLevel_LevelList.value = res.data
        })
  }
}

const houseFundsCalculateForm_PostTypeChange = () => {
  const body = ref({
    postTypeId: houseFundsCalculateForm.value.postTypeId
  })
  houseFundsCalculateForm.value.postId = undefined
  houseFundsCalculateForm.value.levelId = undefined
  SystemPost.querySystemPostByType(body.value)
      .then(res => {
        houseFundsCalculateForm_postList.value = res.data
      })
  SalaryLevel.querySystemLevelByType(body.value)
      .then(res => {
        houseFundsCalculateForm_LevelList.value = res.data
      })
}

const insuranceCalculateForm_PostTypeChange = () => {
  const body = ref({
    postTypeId: insuranceCalculateForm.value.postTypeId
  })
  insuranceCalculateForm.value.postId = undefined
  insuranceCalculateForm.value.levelId = undefined
  SystemPost.querySystemPostByType(body.value)
      .then(res => {
        insuranceCalculateForm_postList.value = res.data
      })
  SalaryLevel.querySystemLevelByType(body.value)
      .then(res => {
        insuranceCalculateForm_LevelList.value = res.data
      })
}

const calculateFileSalary = () => {
  const body = ref({
    postId: salaryFileFormValue.value.filePostId,
    levelId: salaryFileFormValue.value.fileLevelId
  })
  Salary.calculateSalary(body.value)
      .then(res => {
        salaryFileFormValue.value.postDescribe = res.data.postDescribe
        salaryFileFormValue.value.filePostSalary = res.data.postSalary
        salaryFileFormValue.value.levelDescribe = res.data.levelDescribe
        salaryFileFormValue.value.fileLevelSalary = res.data.salaryStandard
      })
}

const levelQuoteFile = () => {
  salaryLevelFormValue.value.postTypeId = salaryFileFormValue.value.filePostTypeId;

  const body = ref({
    postTypeId: salaryLevelFormValue.value.postTypeId
  })
  SalaryLevel.querySystemLevelByType(body.value)
      .then(res => {
        salaryLevel_LevelList.value = res.data
        salaryLevelFormValue.value.levelId = salaryFileFormValue.value.fileLevelId;
      })
}

const managerQuoteFile = () => {
  salaryManageFormValue.value.postTypeId = salaryFileFormValue.value.filePostTypeId;

  const body = ref({
    postTypeId: salaryManageFormValue.value.postTypeId
  })
  SystemPost.querySystemPostByType(body.value)
      .then(res => {
        salaryManage_postList.value = res.data
        salaryManageFormValue.value.postId = salaryFileFormValue.value.filePostId;
      })
}

const oneQuoteFile = () => {
  salaryOneFormValue.value.postTypeId = salaryFileFormValue.value.filePostTypeId;

  const body = ref({
    postTypeId: salaryOneFormValue.value.postTypeId
  })
  SystemPost.querySystemPostByType(body.value)
      .then(res => {
        salaryOne_postList.value = res.data
        salaryOneFormValue.value.postId = salaryFileFormValue.value.filePostId;
      })
}

const twoQuoteFile = () => {
  salaryTwoFormValue.value.postTypeId = salaryFileFormValue.value.filePostTypeId;

  const body = ref({
    postTypeId: salaryTwoFormValue.value.postTypeId
  })
  SystemPost.querySystemPostByType(body.value)
      .then(res => {
        salaryTwo_postList.value = res.data
        salaryTwoFormValue.value.postId = salaryFileFormValue.value.filePostId;
      })
}

const houseFundsCalculateFormQuoteFile = () => {
  houseFundsCalculateForm.value.postTypeId = salaryFileFormValue.value.filePostTypeId;
  if (houseFundsCalculateForm.value.postTypeId) {
    const body = ref({
      postTypeId: houseFundsCalculateForm.value.postTypeId
    })
    SalaryLevel.querySystemLevelByType(body.value)
        .then(res => {
          houseFundsCalculateForm_LevelList.value = res.data
          houseFundsCalculateForm.value.levelId = salaryFileFormValue.value.fileLevelId;
        })
    SystemPost.querySystemPostByType(body.value)
        .then(res => {
          houseFundsCalculateForm_postList.value = res.data
          houseFundsCalculateForm.value.postId = salaryFileFormValue.value.filePostId;
        })
  }
}

const insuranceCalculateFormQuoteFile = () => {
  insuranceCalculateForm.value.postTypeId = salaryFileFormValue.value.filePostTypeId;
  if (insuranceCalculateForm.value.postTypeId) {
    const body = ref({
      postTypeId: insuranceCalculateForm.value.postTypeId
    })
    SalaryLevel.querySystemLevelByType(body.value)
        .then(res => {
          insuranceCalculateForm_LevelList.value = res.data
          insuranceCalculateForm.value.levelId = salaryFileFormValue.value.fileLevelId;
        })
    SystemPost.querySystemPostByType(body.value)
        .then(res => {
          insuranceCalculateForm_postList.value = res.data
          insuranceCalculateForm.value.postId = salaryFileFormValue.value.filePostId;
        })
  }
}

const calculateLevelSalary = () => {
  const body = ref({
    levelId: salaryLevelFormValue.value.levelId
  })
  Salary.calculateSalary(body.value)
      .then(res => {
        salaryLevelFormValue.value.postDescribe = res.data.postDescribe
        salaryLevelFormValue.value.levelDescribe = res.data.levelDescribe
        salaryLevelFormValue.value.levelSalary = res.data.salaryStandard
      })
}

const calculateManagerSalary = () => {
  const body = ref({
    postId: salaryManageFormValue.value.postId
  })
  Salary.calculateSalary(body.value)
      .then(res => {
        salaryManageFormValue.value.postDescribe = res.data.postDescribe
        salaryManageFormValue.value.manager = res.data.manager
        salaryManageFormValue.value.manageAllowance = res.data.manageAllowance
      })
}

const calculateOneSalary = () => {
  const body = ref({
    postId: salaryOneFormValue.value.postId
  })
  Salary.calculateSalary(body.value)
      .then(res => {
        salaryOneFormValue.value.postDescribe = res.data.postDescribe
        salaryOneFormValue.value.postSalary = res.data.postSalary
        salaryOneFormValue.value.performanceAward = res.data.performanceAward
      })
}

const calculateTwoSalary = () => {
  const body = ref({
    postId: salaryTwoFormValue.value.postId
  })
  Salary.calculateSalary(body.value)
      .then(res => {
        salaryTwoFormValue.value.postDescribe = res.data.postDescribe
        salaryTwoFormValue.value.basicAllowance = res.data.basicAllowance
        salaryTwoFormValue.value.postAllowance = res.data.postAllowance
        salaryTwoFormValue.value.achievementAward = res.data.achievementAward
      })
}

const addHouseFunds = () => {
  houseFundsCalculateForm.value.isTeachSeries = salaryFormValue.value.isTeachSeries
  houseFundsCalculateForm.value.governmentStaff = salaryFormValue.value.governmentStaff
  houseFundsDialogVisible.value = true
}
const calculateHouseFunds = () => {
  const body = ref({
    postId: houseFundsCalculateForm.value.postId,
    levelId: houseFundsCalculateForm.value.levelId,
    isTeachSeries: houseFundsCalculateForm.value.isTeachSeries,
    governmentStaff: houseFundsCalculateForm.value.governmentStaff,
  })
  Salary.calculateHouseFunds(body.value)
      .then(res => {
        houseFundsCalculateResult.value.fundCardinalFormula = res.data.fundCardinalFormula
        houseFundsCalculateResult.value.fundCardinal = res.data.fundCardinal
        houseFundsCalculateResult.value.fundStandardFormula = res.data.fundStandardFormula
        houseFundsCalculateResult.value.fundStandard = res.data.fundStandard
      })
}
const houseFundsDialogConfirm = () => {
  if (houseFundsCalculateForm.value.currentYear === 1) {
    salaryHouseFundsFormValue.value.forEach((element) => {
      element.currentYear = 0
    })
  }
  const row = ref({
    fundCardinal: houseFundsCalculateResult.value.fundCardinal,
    fundStandard: houseFundsCalculateResult.value.fundStandard,
    belongYear: houseFundsCalculateForm.value.belongYear,
    currentYear: houseFundsCalculateForm.value.currentYear,
    remark: houseFundsCalculateForm.value.remark,
  })
  salaryHouseFundsFormValue.value.unshift(row.value);
  houseFundsDialogVisible.value = false
}
const handleHouseFundsDelete = (index) => {
  salaryHouseFundsFormValue.value.splice(index, 1);
}

const insuranceCalculateTools = () => {
  insuranceCalculateForm.value.governmentStaff = salaryFormValue.value.governmentStaff
  insuranceDialogVisible.value = true
}
const calculateInsurance = () => {
  const body = ref({
    postId: insuranceCalculateForm.value.postId,
    levelId: insuranceCalculateForm.value.levelId,
    governmentStaff: insuranceCalculateForm.value.governmentStaff,
  })
  Salary.calculateInsurance(body.value)
      .then(res => {
        insuranceCalculateResult.value.socialCardinal = res.data.socialCardinal
        insuranceCalculateResult.value.socialCardinalFormula = res.data.socialCardinalFormula
        insuranceCalculateResult.value.medicalCardinal = res.data.medicalCardinal
        insuranceCalculateResult.value.medicalCardinalFormula = res.data.medicalCardinalFormula
        insuranceCalculateResult.value.endowmentCardinal = res.data.endowmentCardinal
        insuranceCalculateResult.value.endowmentCardinalFormula = res.data.endowmentCardinalFormula
        insuranceCalculateResult.value.medicalInsurance = res.data.medicalInsurance
        insuranceCalculateResult.value.medicalInsuranceFormula = res.data.medicalInsuranceFormula
        insuranceCalculateResult.value.careerInsurance = res.data.careerInsurance
        insuranceCalculateResult.value.careerInsuranceFormula = res.data.careerInsuranceFormula
        insuranceCalculateResult.value.endowmentInsurance = res.data.endowmentInsurance
        insuranceCalculateResult.value.endowmentInsuranceFormula = res.data.endowmentInsuranceFormula
        insuranceCalculateResult.value.occupationAnnuity = res.data.occupationAnnuity
        insuranceCalculateResult.value.occupationAnnuityFormula = res.data.occupationAnnuityFormula
        insuranceCalculateResult.value.unionDues = res.data.unionDues
        insuranceCalculateResult.value.unionDuesFormula = res.data.unionDuesFormula
      })
}
const insuranceDialogConfirm = () => {
  salaryInsuranceFormValue.value.socialCardinal = insuranceCalculateResult.value.socialCardinal
  salaryInsuranceFormValue.value.medicalCardinal = insuranceCalculateResult.value.medicalCardinal
  salaryInsuranceFormValue.value.endowmentCardinal = insuranceCalculateResult.value.endowmentCardinal
  salaryInsuranceFormValue.value.medicalInsurance = insuranceCalculateResult.value.medicalInsurance
  salaryInsuranceFormValue.value.careerInsurance = insuranceCalculateResult.value.careerInsurance
  salaryInsuranceFormValue.value.endowmentInsurance = insuranceCalculateResult.value.endowmentInsurance
  salaryInsuranceFormValue.value.occupationAnnuity = insuranceCalculateResult.value.occupationAnnuity
  salaryInsuranceFormValue.value.unionDues = insuranceCalculateResult.value.unionDues
  insuranceDialogVisible.value = false
}

const update = () => {
  salaryFormValue.value.salaryFile=salaryFileFormValue.value
  salaryFormValue.value.salaryLevel=salaryLevelFormValue.value
  salaryFormValue.value.salaryManage=salaryManageFormValue.value
  salaryFormValue.value.salaryOne=salaryOneFormValue.value
  salaryFormValue.value.salaryTwo=salaryTwoFormValue.value
  salaryFormValue.value.salarySubsidy=salarySubsidyFormValue.value
  salaryFormValue.value.salaryHouseFunds=salaryHouseFundsFormValue.value
  salaryFormValue.value.salaryInsurance=salaryInsuranceFormValue.value
  salaryFormValue.value.salaryRetire=salaryRetireFormValue.value
  loading.value = true
  Salary.updateSalary(salaryFormValue.value)
      .then(res => {
        //重新获取详情
        getSalaryDetail()
        ElMessage.success('更新成功')
        loading.value = false
      })
      .catch(error => {
        loading.value = false
      })
}
const save = () => {
  salaryFormValue.value.userId = userInfoFormValue.value.id
  salaryFormValue.value.salaryFile=salaryFileFormValue.value
  salaryFormValue.value.salaryLevel=salaryLevelFormValue.value
  salaryFormValue.value.salaryManage=salaryManageFormValue.value
  salaryFormValue.value.salaryOne=salaryOneFormValue.value
  salaryFormValue.value.salaryTwo=salaryTwoFormValue.value
  salaryFormValue.value.salarySubsidy=salarySubsidyFormValue.value
  salaryFormValue.value.salaryHouseFunds=salaryHouseFundsFormValue.value
  salaryFormValue.value.salaryInsurance=salaryInsuranceFormValue.value
  loading.value = true
  Salary.addSalary(salaryFormValue.value)
      .then(res => {
        //重新获取详情
        getSalaryDetail()
        ElMessage.success('保存成功')
        loading.value = false
      })
      .catch(error => {
        loading.value = false
      })
}


onMounted(() => {
  userId.value = route.query.userId;

  const body=ref({
    userId:userId.value
  })

  // 获取部门列表
  listAllDept()

  //获取岗位类别
  querySystemPostType()

  //获取详情
  getUserSimpleDetail(body.value)
});

const listAllDept = () => {
  Dept.listAllDept()
      .then(res => {
        deptData.value = res.data
      })
};

//获取岗位类别
const querySystemPostType = () => {
  SystemPostType.querySystemPostType()
      .then(res => {
        systemPostTypeList.value = res.data
      })
};

//获取用户简单详情
const getUserSimpleDetail = (data) => {
  userLoading.value = true
  UserBasic.getUserSimpleDetail(data)
      .then(res => {
        userInfoFormValue.value = res.data
        userLoading.value = false
      })
      .catch(error => {
        userLoading.value = false
      })
};

//获取详情
const getSalaryDetail = async () => {
  loading.value = true

  const body=ref({
    userId:userId.value
  })

  Salary.getSalaryDetail(body.value)
      .then(res => {
        salaryFormValue.value = res.data

        salaryFileFormValue.value = res.data.salaryFile
        salaryFile_PostTypeChange()

        salaryLevelFormValue.value = res.data.salaryLevel
        salaryLevel_PostTypeChange()

        salaryManageFormValue.value = res.data.salaryManage
        salaryManager_PostTypeChange()

        salaryOneFormValue.value = res.data.salaryOne
        salaryOne_PostTypeChange()

        salaryTwoFormValue.value = res.data.salaryTwo
        salaryTwo_PostTypeChange()

        salarySubsidyFormValue.value = res.data.salarySubsidy
        salaryHouseFundsFormValue.value = res.data.salaryHouseFunds
        salaryInsuranceFormValue.value = res.data.salaryInsurance
        if (res.data.salaryRetire) {
          salaryRetireFormValue.value = res.data.salaryRetire
        }

        loading.value = false
      })
      .catch(error => {
        loading.value = false
      })
};

//获取详情
const getSalaryFormValue = () => {
  salaryFormValue.value.userId = userInfoFormValue.value.id
  salaryFormValue.value.salaryFile=salaryFileFormValue.value
  salaryFormValue.value.salaryLevel=salaryLevelFormValue.value
  salaryFormValue.value.salaryManage=salaryManageFormValue.value
  salaryFormValue.value.salaryOne=salaryOneFormValue.value
  salaryFormValue.value.salaryTwo=salaryTwoFormValue.value
  salaryFormValue.value.salarySubsidy=salarySubsidyFormValue.value
  salaryFormValue.value.salaryHouseFunds=salaryHouseFundsFormValue.value
  salaryFormValue.value.salaryInsurance=salaryInsuranceFormValue.value
  return salaryFormValue.value
};

defineExpose({
  getSalaryDetail, save, update, getSalaryFormValue
});

</script>

<style scoped>
.tabs > .el-tabs__content {
  padding: 32px;
  color: #6b778c;
  font-size: 32px;
  font-weight: 600;
}
</style>